package com.ycw.servlet.wangwang;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;
import com.ycw.dao.ContractDao;
import com.ycw.dao.impl.ContractDaoImpl;
import com.ycw.pojo.Contract;
import com.ycw.pojo.pageIndex;

@WebServlet("/doGetAllContractServlet")
public class doGetAllContractServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		ContractDao cd = new ContractDaoImpl();
		String pageIndexCon = request.getParameter("pageIndex");
		int pageIndex = Integer.parseInt(pageIndexCon);
		pageIndex pa = new pageIndex();
		pa.setPageIndex(pageIndex);
		List<Contract> map = cd.contractGetAll(pa);
		// 向前端发送JSON数据
		String resJSON = JSON.toJSONString(map);
		PrintWriter out = response.getWriter();
		out.write(resJSON);
		out.close();
	}

}
